'ui';
setScreenMetrics(720, 1280);
var color = '#cc35fa'; //左侧菜单icon颜色
var time = 0;
var storage = storages.create('configure'); //建立本地存储
var variables = {}; //存储全局变量
variables.threads = {}; //在全局变量variables中建立数组threads管理已经打开的所有任务线程
variables.timer_threads = {}; //在全局变量variables中建立空对象timer_threads管理已经打开的定时器线程
variables.configure = {}; //在全局变量variables中建立空对象存储配置信息
var { configure_page } = require('./configurePpage.js');
var { about_page } = require('./aboutPage.js');
var xf_h = storage.get('configure').xfan1 ? 40 : 108;
xf_w = storage.get('configure').xfan1 ? 135 : 90;
xf_mg = storage.get('configure').xfan1 ? 5 : 39;

var welcomeLayout = ui.inflate(
    <vertical id="box" bg="file://img/zy.png" clickable="true">
        <vertical w="*" h="*" layout_gravity="center">
            <vertical w="*" layout_weight="1">
                <text w="*" textColor="#e787ff" textSize="18sp" margin="60 20 0 0" className="t1" text="醉" />
                <text w="*" textColor="#e787ff" textSize="18sp" margin="60 20 0 0" className="t1" text="后" />
                <text w="*" textColor="#e787ff" textSize="18sp" margin="60 20 0 0" className="t1" text="不" />
                <text w="*" textColor="#e787ff" textSize="18sp" margin="60 20 0 0" className="t1" text="知" />
                <text w="*" textColor="#e787ff" textSize="18sp" margin="60 20 0 0" className="t1" text="天" />
                <text w="*" textColor="#e787ff" textSize="18sp" margin="60 20 0 0" className="t1" text="在" />
                <text w="*" textColor="#e787ff" textSize="18sp" margin="60 20 0 0" className="t1" text="水" />
            </vertical>
            <vertical w="*" textColor="#e787ff" textSize="18sp" marginTop="20" layout_weight="1">
                <text
                    w="*"
                    textColor="#e787ff"
                    textSize="18sp"
                    gravity="right"
                    margin="0 20 60 0"
                    className="t2"
                    text="满"
                />
                <text
                    w="*"
                    textColor="#e787ff"
                    textSize="18sp"
                    gravity="right"
                    margin="0 20 60 0"
                    className="t2"
                    text="船"
                />
                <text
                    w="*"
                    textColor="#e787ff"
                    textSize="18sp"
                    gravity="right"
                    margin="0 20 60 0"
                    className="t2"
                    text="清"
                />
                <text
                    w="*"
                    textColor="#e787ff"
                    textSize="18sp"
                    gravity="right"
                    margin="0 20 60 0"
                    className="t2"
                    text="梦"
                />
                <text
                    w="*"
                    textColor="#e787ff"
                    textSize="18sp"
                    gravity="right"
                    margin="0 20 60 0"
                    className="t2"
                    text="压"
                />
                <text
                    w="*"
                    textColor="#e787ff"
                    textSize="18sp"
                    gravity="right"
                    margin="0 20 60 0"
                    className="t2"
                    text="星"
                />
                <text
                    w="*"
                    textColor="#e787ff"
                    textSize="18sp"
                    gravity="right"
                    margin="0 20 60 0"
                    className="t2"
                    text="河"
                />
            </vertical>
            <horizontal w="*" h="auto">
                <img
                    id="skip"
                    layout_weight="1"
                    alpha="1.0"
                    w="50"
                    h="50"
                    src="file://img/tx.png"
                    circle="true"
                    layout_gravity="left"
                    margin="20 30"
                    clickable="true"
                />
                <img
                    id="gtx"
                    layout_weight="1"
                    alpha="1.0"
                    w="50"
                    h="50"
                    src="file://img/gtx.png"
                    circle="true"
                    layout_gravity="left"
                    margin="20 30"
                    clickable="true"
                />
            </horizontal>
        </vertical>
    </vertical>
);

var layout1 = ui.inflate(
    <drawer id="drawer" bg="#cecece">
        <vertical>
            <toolbar id="toolbar" layout_weight="1" title="星意" />
            <viewpager id="viewpager" layout_weight="8">
                {/* 必做任务 */}
                <vertical bg="file://img/zsbg.png">
                    <text bg="?attr/selectableItemBackground" clickable="true" text=" 请选择要自动执行的操作" />
                    <checkbox id="cxdt" text="惩凶打图" />
                    <checkbox id="shyh" text="山河映画" />
                    <checkbox id="bhyw" text="帮会演武" />
                    <linear>
                        <checkbox id="bhrw" text="帮会任务" />
                        <checkbox id="ztks_bh" text="中途开始" />
                        <spinner id="xl_bhrw" entries="声威赫-3星|八斗才-4星|百物丰-5星" marginLeft="30" />
                    </linear>
                    <radiogroup orientation="horizontal"></radiogroup>
                    <checkbox id="xy" text="一千零一个愿望" />
                    <linear>
                        <checkbox id="smrw" text="师门任务" />
                        <checkbox id="ztks_sm" text="中途开始" />
                    </linear>
                    <checkbox id="allSele" text="全选" marginTop="15" />
                    <button text="开始执行" id="bzrw" style="Widget.AppCompat.Button.Colored" />
                    <linear gravity="center">
                        <checkbox id="dsks1" text="定时开始" />
                        <checkbox id="dsjs1" text="定时结束" marginLeft="40" />
                    </linear>
                </vertical>
                {/* 多人副本 */}
                <vertical bg="file://img/zsbg.png">
                    <text bg="?attr/selectableItemBackground" clickable="true" text=" 请选择要自动执行的操作" />
                    <linear>
                        <checkbox id="ytl" text="一条龙" />
                        <checkbox id="syyb" text="使用佣兵" />
                    </linear>
                    <spinner
                        id="ytl_jsh"
                        entries="结束后挂地宫|结束后离线挂地宫|结束后挂古墓|结束后离线挂古墓|结束后回城"
                        marginLeft="30"
                    />
                    <checkbox id="allSele1" text="全选" marginTop="15" />
                    <button text="开始执行" id="drfb" style="Widget.AppCompat.Button.Colored" />
                    <linear gravity="center">
                        <checkbox id="dsks2" text="定时开始" />
                        <checkbox id="dsjs2" text="定时结束" marginLeft="40" />
                    </linear>
                </vertical>
                {/* 闲暇任务 */}
                <vertical bg="file://img/zsbg.png">
                    <text bg="?attr/selectableItemBackground" clickable="true" text=" 请选择要自动执行的操作" />
                    <checkbox id="dbmz" text="夺宝马贼" marginTop="15" />
                    <checkbox id="ps" text="跑商" />
                    <checkbox id="wcbt" text="挖藏宝图" />
                    <linear>
                        <checkbox id="gdg" text="挂地宫" />
                        <spinner id="xl_gdg" entries="我是队长|我是队员" marginLeft="20" />
                        <spinner id="xl_gj" entries="挂地宫|离线挂地宫|挂古墓|离线挂古墓" />
                    </linear>
                    <checkbox id="hzc" text="回主城" />
                    <checkbox id="qhjs" text="切换角色" />
                    <input id="roleName" hint="请输入要切换的角色名(模糊查找)" />
                    <button text="开始执行" id="xxrw" style="Widget.AppCompat.Button.Colored" />
                    <linear gravity="center">
                        <checkbox id="dsks3" text="定时开始" />
                        <checkbox id="dsjs3" text="定时结束" marginLeft="40" />
                    </linear>
                </vertical>
                {/* 限时任务 */}
                <vertical bg="file://img/zsbg.png">
                    <text
                        id="rwxz"
                        bg="?attr/selectableItemBackground"
                        clickable="true"
                        text=" 请选择要自动执行的操作"
                    />
                    <checkbox id="zlqj" text="珍珑棋局" />
                    <checkbox id="xl" text="小龙" />
                    <checkbox id="bhyb" text="帮会运镖" />
                    <checkbox id="bhyy" text="帮会饮宴" />
                    <checkbox id="allSele3" text="全选" marginTop="15" />
                    <button text="开始执行" id="xsrw" style="Widget.AppCompat.Button.Colored" />
                    <linear gravity="center">
                        <checkbox id="dsks4" text="定时开始" />
                        <checkbox id="dsjs4" text="定时结束" marginLeft="40" />
                    </linear>
                </vertical>
            </viewpager>
            <appbar>
                <frame>
                    <tabs id="tabs" layout_weight="1" w="*" bg="#d0bbe4" />
                    <horizontal>
                        <vertical layout_weight="1" gravity="center">
                            <img w="30" h="30" circle="true" src="file://img/bz.png" />
                            <text text="必做任务" gravity="center" />
                        </vertical>
                        <vertical layout_weight="1" gravity="center">
                            <img w="30" h="30" circle="true" src="file://img/fb.png" />
                            <text text="多人副本" gravity="center" />
                        </vertical>
                        <vertical layout_weight="1" gravity="center">
                            <img w="30" h="30" circle="true" src="file://img/xx.png" />
                            <text text="闲暇任务" gravity="center" />
                        </vertical>
                        <vertical layout_weight="1" gravity="center">
                            <img w="30" h="30" circle="true" src="file://img/tz.png" />
                            <text text="限时任务" gravity="center" />
                        </vertical>
                    </horizontal>
                </frame>
            </appbar>
        </vertical>
        <vertical layout_gravity="left" bg="#fefefe" w="280">
            <img w="280" h="200" scaleType="fitXY" src="file://img/xy.png" />
            <list id="menu">
                <horizontal bg="?selectableItemBackground" w="*">
                    <img w="50" h="50" padding="16" src="{{this.icon}}" tint="{{color}}" />
                    <text textColor="black" textSize="15sp" text="{{this.title}}" layout_gravity="center" />
                </horizontal>
            </list>
        </vertical>
    </drawer>
);
ui.setContentView(welcomeLayout);

//创建选项菜单(右上角)
ui.emitter.on('create_options_menu', menu => {
    menu.add('设置');
    menu.add('关于');
});

//监听选项菜单点击

ui.emitter.on('options_item_selected', (e, item) => {
    switch (item.getTitle()) {
        case '设置':
            ui.setContentView(configure_page);
            break;
        case '关于':
            ui.setContentView(about_page);
            break;
    }
    e.consumed = true;
});

importClass(android.view.MenuItem);
ui.emitter.on('create_options_menu', menu => {
    //添加按钮
    item = menu.add(0, 2, 0, '启动');
    item.setIcon(getDrawable('./icon/game_icon.png', 120));
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    return true;
}); //toolbar添加自定义按钮

importClass(android.graphics.Bitmap);
function getDrawable(filePath, size) {
    size = size || 30;
    let oldBmp = images.read(filePath).getBitmap();
    let newBmp = Bitmap.createScaledBitmap(oldBmp, size, size, true);
    return new BitmapDrawable(newBmp);
} //自定义位图

ui.emitter.on('options_item_selected', (e, item) => {
    switch (item.getTitle()) {
        case '启动':
            var qdyx = threads.start(() => {
                app.launchApp('新天龙八部');
                toastLog('启动游戏');
                qdyx.interrupt();
            });
            break;
    }
    e.consumed = true;
}); //设置点击（选中）事件

//屏蔽返回键重新设置
events.setKeyInterceptionEnabled('back', true);
events.observeKey();
var time0 = null;
events.onKeyDown('back', event => {
    time1 = event.eventTime;
    time_diff = time1 - time0;
    time0 = time1;
    if (time_diff < 1000) {
        ui.finish();
    } else {
        ui.setContentView(layout1);
        toastLog('再按一次退出应用');
    }
});

//保存控件的初始位置
var skipX, skipY;
//保存手指按下的初始位置
var x0 = 0,
    y0 = 0;
//另一图片位置
var x1, y1;
//操作页面layout1入口
welcomeLayout.skip.setOnTouchListener(function (view, event) {
    switch (event.getAction()) {
        case event.ACTION_DOWN:
            //记录skip控件的起始位置
            skipX = ui.skip.getX();
            skipY = ui.skip.getY();

            //记录另一头像的位置用于判断距离
            x1 = ui.gtx.getX();
            y1 = ui.gtx.getY();

            //记录手指按下的位置
            x0 = event.getRawX();
            y0 = event.getRawY();
            return true;
        case event.ACTION_MOVE:
            ui.skip.setX(skipX + event.getRawX() - x0);
            ui.skip.setY(skipY + event.getRawY() - y0);
            return true;
        case event.ACTION_UP:
            if (Math.abs(ui.skip.getX() - x1) < 50 && Math.abs(ui.skip.getY() - y1) < 50) {
                ui.setContentView(layout1);
                //设置的当前页面状态栏颜色
                ui.statusBarColor('#d0bbe4');
                //设置滑动页面的标题
                ui.viewpager.setTitles(['     ', '     ', '     ', '     ']);

                activity.setSupportActionBar(ui.toolbar);

                //让滑动页面和标签栏联动
                ui.tabs.setupWithViewPager(ui.viewpager);

                //让工具栏左上角可以打开侧拉菜单
                ui.toolbar.setupWithDrawer(ui.drawer);

                ui.menu.setDataSource([
                    {
                        title: '打开悬浮窗',
                        icon: '@drawable/ic_android_black_48dp',
                    },
                    {
                        title: '检查更新',
                        icon: '@drawable/ic_settings_black_48dp',
                    },
                    {
                        title: '还没想好',
                        icon: '@drawable/ic_favorite_black_48dp',
                    },
                    {
                        title: '退出',
                        icon: '@drawable/ic_exit_to_app_black_48dp',
                    },
                ]);
                ui.menu.on('item_click', item => {
                    switch (item.title) {
                        case '退出':
                            ui.finish();
                            break;
                        case '打开悬浮窗':
                            threads.start(function () {
                                if (b1) {
                                } else {
                                    b1 = threads.start(function () {
                                        w = require('./floatyWindow.js').window;
                                    });
                                }
                            });
                            break;
                        case '检查更新':
                            threads.start(function () {
                                var zxUpdate = require('./update.js').zxUpdate;
                                zxUpdate();
                            });
                            break;
                    }
                });
                importClass(android.graphics.drawable.BitmapDrawable);
                let bmp = images.read('./img/bg.png').getBitmap();
                ui.toolbar.setBackgroundDrawable(new BitmapDrawable(bmp));
            } else {
                ui.skip.setX(skipX);
                ui.skip.setY(skipY);
                toast('请滑动头像到指定位置进入操作界面');
            }
            return true;
    }
    return true;
});

/**
 * 必做任务页(多选框全选逻辑)
 */
layout1.allSele.on('click', () => {
    if (layout1.allSele.isChecked()) {
        layout1.cxdt.setChecked(true);
        layout1.shyh.setChecked(true);
        layout1.bhyw.setChecked(true);
        layout1.bhrw.setChecked(true);
        layout1.xy.setChecked(true);
        layout1.smrw.setChecked(true);
    } else {
        layout1.cxdt.setChecked(false);
        layout1.shyh.setChecked(false);
        layout1.bhyw.setChecked(false);
        layout1.bhrw.setChecked(false);
        layout1.xy.setChecked(false);
        layout1.smrw.setChecked(false);
    }
});
function pd() {
    if (
        layout1.cxdt.isChecked() &&
        layout1.shyh.isChecked() &&
        layout1.bhyw.isChecked() &&
        layout1.bhrw.isChecked() &&
        layout1.xy.isChecked() &&
        layout1.smrw.isChecked()
    ) {
        layout1.allSele.setChecked(true);
    } else {
        layout1.allSele.setChecked(false);
    }
}

layout1.cxdt.on('check', () => {
    pd();
});
layout1.shyh.on('check', () => {
    pd();
});
layout1.bhyw.on('check', () => {
    pd();
});
layout1.bhrw.on('check', () => {
    pd();
});
layout1.xy.on('check', () => {
    pd();
});
layout1.smrw.on('check', () => {
    pd();
});
//多人副本页
layout1.allSele1.on('click', () => {
    if (layout1.allSele1.isChecked()) {
        layout1.ytl.setChecked(true);
    } else {
        layout1.ytl.setChecked(false);
    }
});
layout1.ytl.on('check', () => {
    if (layout1.ytl.isChecked()) {
        layout1.allSele1.setChecked(true);
    } else {
        layout1.allSele1.setChecked(false);
    }
});
layout1.ytl.on('check', () => {
    pd();
});
//限时任务页
layout1.allSele3.on('click', () => {
    if (layout1.allSele3.isChecked()) {
        layout1.zlqj.setChecked(true);
        layout1.xl.setChecked(true);
        layout1.bhyb.setChecked(true);
        layout1.bhyy.setChecked(true);
    } else {
        layout1.zlqj.setChecked(false);
        layout1.xl.setChecked(false);
        layout1.bhyb.setChecked(false);
        layout1.bhyy.setChecked(false);
    }
});
function pd3() {
    if (
        layout1.zlqj.isChecked() &&
        layout1.xl.isChecked() &&
        layout1.bhyy.isChecked() &&
        layout1.bhyb.isChecked() &&
        layout1.bhyy.isChecked()
    ) {
        layout1.allSele3.setChecked(true);
    } else {
        layout1.allSele3.setChecked(false);
    }
}
layout1.zlqj.on('check', () => {
    pd3();
});
layout1.xl.on('check', () => {
    pd3();
});
layout1.bhyb.on('check', () => {
    pd3();
});
layout1.bhyy.on('check', () => {
    pd3();
});
//闲暇任务页
var isFirst = true; // 定义一个变量isFirst，标记是否第一次选择Spinner选项。
var myAdapterListener = new android.widget.AdapterView.OnItemSelectedListener({
    // 创建一个OnItemSelectedListener监听器。
    onItemSelected: function (parent, view, position, id) {
        if (id == 0) {
            ui.xl_gj.visibility = 0;
        } else {
            ui.xl_gj.visibility = 8;
        }
    },
});

layout1.xl_gdg.setOnItemSelectedListener(myAdapterListener);
/**
 * ui和脚本功能对接区
 */

var pause_flag = require('./foo.js').pause_flag;
var do_bzrw = require('./bzrw.js').do_bzrw;
var do_drfb = require('./drfb.js').do_drfb;
var do_xsrw = require('./xsrw.js').do_xsrw;
var do_xxrw = require('./xxrw.js').do_xxrw;

/*对应4个功能页开始执行按钮*/

//请求截图权限
threads.start(function () {
    images.requestScreenCapture(true);
});
var w = null; //控制悬浮窗是否显示
layout1.bzrw.on('click', () => {
    threads.start(() => {
        if (layout1.bzrw.getText() == '开始执行') {
            //点击开始执行后打开悬浮窗
            b1
                ? null
                : (b1 = threads.start(function () {
                      w = require('./floatyWindow.js').window;
                  }));

            variables.threads.a1 = ''; //先在存储了所有任务线程的对象里占位
            var arr_threads_name = Object.keys(variables.threads); //存储所有线程变量名的数组
            if (arr_threads_name.length >= 2) {
                //前边有未做完的任务，等待做完后开启任务线程
                last_thread_name = arr_threads_name[arr_threads_name.length - 2]; //拿到除了本身线程之外的最后一个线程变量名
                variables.threads.a1 = threads.start(function () {
                    variables.threads[last_thread_name].join(0); //等待前一个线程完成后开始
                    do_bzrw();
                });
            } else {
                //直接开启辅助操作线程
                variables.threads.a1 = threads.start(function () {
                    do_bzrw();
                });
            }

            layout1.bzrw.setText('停止执行');
        } else {
            if (variables.threads.a1) {
                if (variables.threads.a1.isAlive()) {
                    variables.threads.a1.interrupt();
                }
                delete variables.threads.a1;
            }
            layout1.bzrw.setText('开始执行');
        }
    });
});
layout1.drfb.on('click', () => {
    threads.start(() => {
        if (layout1.drfb.getText() == '开始执行') {
            b1
                ? null
                : (b1 = threads.start(function () {
                      w = require('./floatyWindow.js').window;
                  }));

            variables.threads.a2 = ''; //先在存储了所有任务线程的对象里占位
            var arr_threads_name = Object.keys(variables.threads); //存储所有线程变量名的数组
            if (arr_threads_name.length >= 2) {
                //前边有未做完的任务，等待做完后开启任务线程
                console.log(arr_threads_name, variables.threads);
                last_thread_name = arr_threads_name[arr_threads_name.length - 2]; //拿到除了本身线程之外的最后一个线程变量名
                variables.threads.a2 = threads.start(function () {
                    variables.threads[last_thread_name].join(0); //等待前一个线程完成后开始
                    do_drfb();
                });
            } else {
                //直接开启辅助操作线程
                variables.threads.a2 = threads.start(function () {
                    do_drfb();
                });
            }
            layout1.drfb.setText('停止执行');
        } else {
            if (variables.threads.a2) {
                if (variables.threads.a2.isAlive()) {
                    variables.threads.a2.interrupt();
                }
                delete variables.threads.a2;
            }
            layout1.drfb.setText('开始执行');
        }
    });
});
layout1.xsrw.on('click', () => {
    threads.start(() => {
        if (layout1.xsrw.getText() == '开始执行') {
            b1
                ? null
                : (b1 = threads.start(function () {
                      w = require('./floatyWindow.js').window;
                  }));

            variables.threads.a3 = ''; //先在存储了所有任务线程的对象里占位
            var arr_threads_name = Object.keys(variables.threads); //存储所有线程变量名的数组
            if (arr_threads_name.length >= 2) {
                //前边有未做完的任务，等待做完后开启任务线程
                last_thread_name = arr_threads_name[arr_threads_name.length - 2]; //拿到除了本身线程之外的最后一个线程变量名
                variables.threads.a3 = threads.start(function () {
                    variables.threads[last_thread_name].join(0); //等待前一个线程完成后开始
                    do_xsrw();
                });
            } else {
                //直接开启辅助操作线程
                variables.threads.a3 = threads.start(function () {
                    do_xsrw();
                });
            }
            layout1.xsrw.setText('停止执行');
        } else {
            if (variables.threads.a3) {
                if (variables.threads.a3.isAlive()) {
                    variables.threads.a3.interrupt();
                }
                delete variables.threads.a3;
            }
            layout1.xsrw.setText('开始执行');
        }
    });
});
layout1.xxrw.on('click', () => {
    threads.start(() => {
        if (layout1.xxrw.getText() == '开始执行') {
            b1
                ? null
                : (b1 = threads.start(function () {
                      w = require('./floatyWindow.js').window;
                  }));

            variables.threads.a4 = ''; //先在存储了所有任务线程的对象里占位
            var arr_threads_name = Object.keys(variables.threads); //存储所有线程变量名的数组
            if (arr_threads_name.length >= 2) {
                //前边有未做完的任务，等待做完后开启任务线程
                last_thread_name = arr_threads_name[arr_threads_name.length - 2]; //拿到除了本身线程之外的最后一个线程变量名
                variables.threads.a4 = threads.start(function () {
                    variables.threads[last_thread_name].join(0); //等待前一个线程完成后开始
                    do_xxrw();
                });
            } else {
                //直接开启辅助操作线程
                variables.threads.a4 = threads.start(function () {
                    do_xxrw();
                });
            }
            ui.run(() => {
                layout1.xxrw.setText('停止执行');
            });
        } else {
            if (variables.threads.a4) {
                if (variables.threads.a4.isAlive()) {
                    variables.threads.a4.interrupt();
                    variables.threads.threads_fqkq ? variables.threads.threads_fqkq.interrupt() : null; //藏宝图找放弃开启单独线程
                }
                delete variables.threads.a4;
            }
            ui.run(() => {
                layout1.xxrw.setText('开始执行');
            });
        }
    });
});

/*对应4个功能页定时开始与定时结束多选框*/

//定义定时开始时间和定时结束时间的初始值
var start_Time1 = null,
    finish_Time1 = null;
var start_Time2 = null,
    finish_Time2 = null;
var start_Time3 = null,
    finish_Time3 = null;
var start_Time4 = null,
    finish_Time4 = null;
//定时开始的线程初始值
var s_timer1 = null,
    finish_thread1 = null,
    f_timer1 = null;
var s_timer2 = null,
    finish_thread2 = null,
    f_timer2 = null;
var s_timer3 = null,
    finish_thread3 = null,
    f_timer3 = null;
var s_timer4 = null,
    finish_thread4 = null,
    f_timer4 = null;

var { checkHandle, planToDo, findText } = require('./foo.js');
var xx = 0; //定时器线程创建索引
var b1 = null; //悬浮窗

//必做任务定时开始与结束
planToDo(layout1.dsks1, layout1.dsjs1, do_bzrw, 'a1', start_Time1, finish_Time1, s_timer1, finish_thread1, f_timer1);

//多人副本定时开始与结束
planToDo(layout1.dsks2, layout1.dsjs2, do_drfb, 'a2', start_Time2, finish_Time2, s_timer2, finish_thread2, f_timer2);

//闲暇任务定时开始与结束
planToDo(layout1.dsks3, layout1.dsjs3, do_xxrw, 'a4', start_Time3, finish_Time3, s_timer3, finish_thread3, f_timer3);

//限时任务定时开始与结束
planToDo(layout1.dsks4, layout1.dsjs4, do_xsrw, 'a3', start_Time4, finish_Time4, s_timer4, finish_thread4, f_timer4);
